#ifndef FND_SOUND_MANAGER_HPP
#define FND_SOUND_MANAGER_HPP
#include <boost/ptr_container/ptr_map.hpp>
#include <sfml/audio.hpp>
#include <stlsoft/shims/access/string.hpp>
#include <string>
namespace FndGame2D {
    class sound_manager {
        typedef boost::ptr_map<std::string,
                               sf::Sound> sound_manager_map ;
        typedef boost::ptr_map<std::string,
                               sf::Music> music_manager_map ;
    public:
        typedef std::string key_type ;
        typedef sf::Sound value_type ;
        typedef sound_manager class_type ;
    public:
        bool add_sound(const key_type& k,
                       value_type* sound) ;
        bool add_music(const key_type& k,
                       sf::Music* music) ;
        bool add_music(const key_type& k,
                       const char* file_name,
size_t buffer_size = 44100) ;
        template<typename Str>
        bool add_music(const key_type& k ,
                       Str s,
size_t buffer_size = 44100) {
            return add_music(k, stlsoft::c_str_ptr(s), buffer_size) ;
        }
        bool add_sound(const key_type& k,
                       sf::SoundBuffer* buffer,
                       bool loop = false,
                       float pitch = 1.f,
                       float valume = 100.f,
                       const sf::Vector3f& position = sf::Vector3f(0.f,0.f,0.f)) ;
        value_type& get_sound(const key_type& k) {
            return m_sound_mgr[k] ;
        }
        sf::Music& get_music(const key_type& k) {
            return m_music_mgr[k] ;
        }
        bool add_music(const key_type& k,
                       size_t buffer_size = 44100) ;
        bool has_sound(const key_type& k) const  {
            return m_sound_mgr.find(k) != m_sound_mgr.end() ;
        }
        bool has_music(const key_type& k) const {
            return m_music_mgr.find(k) != m_music_mgr.end() ;
        }
    private:
        sound_manager_map m_sound_mgr ;
        music_manager_map m_music_mgr ;
    } ;
}
#endif  // FND_SOUND_MANAGER_HPP
